﻿message(">>>>>>>>>>>>>>>>> PROJECT LINUX INSTALL PROJECT: " ${PROJECT_NAME})
message(">>>>>>>>>>>>>>>>> PROJECT LINUX INSTALL PATH: " ${CMAKE_INSTALL_PREFIX})

if( ${DEBUG_PROJECT_INTERNAL} )
    set(CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}/DebugProjects/${PROJECT_NAME})
    message(">>>>>>>>>>>>>>>>> PROJECT LINUX BINARY DIR IN DEBUG: " ${CMAKE_BINARY_DIR})
    install(DIRECTORY ${DIR_ROOT}/Assets DESTINATION ${CMAKE_INSTALL_PREFIX})
    install(DIRECTORY ${ENGINE_ROOT_PATH}/Assets/Shaders/GLSL_SRC DESTINATION ${CMAKE_INSTALL_PREFIX}/EngineAssets/Shaders)
    install(DIRECTORY ${ENGINE_ROOT_PATH}/Assets/Textures/ DESTINATION ${CMAKE_INSTALL_PREFIX}/EngineAssets/Textures)
    #INSTALL DEPENDENT SO
    install(DIRECTORY ${CMAKE_INSTALL_PREFIX}/../../Engine/ DESTINATION ${CMAKE_INSTALL_PREFIX}/libs/${TARGET_ABI})
    install(FILES ${CMAKE_BINARY_DIR}/libNSProject.so DESTINATION ${CMAKE_INSTALL_PREFIX}/libs/${TARGET_ABI})
	if( EXISTS "${DIR_ROOT}/Libs/${TARGET_ABI}/" )
		install(DIRECTORY ${DIR_ROOT}/Libs/${TARGET_ABI}/ DESTINATION ${CMAKE_INSTALL_PREFIX}/libs/${TARGET_ABI})
	endif()
elseif( ${NS_CROSS_DEBUG})
    message(">>>>>>>>>>>>>>>>> PROJECT LINUX CORSS DEBUG INSTALL PATH: " ${CMAKE_INSTALL_PREFIX})
    install(DIRECTORY ${DIR_ROOT}/Assets DESTINATION ${CMAKE_INSTALL_PREFIX})
    install(DIRECTORY ${ENGINE_ROOT_PATH}/EngineAssets/Shaders/GLSL_SRC DESTINATION ${CMAKE_INSTALL_PREFIX}/EngineAssets/Shaders)
    install(DIRECTORY ${ENGINE_ROOT_PATH}/EngineAssets/Textures DESTINATION ${CMAKE_INSTALL_PREFIX}/EngineAssets)
    #INSTALL DEPENDENT LIB. DIR LIB IS NS ENGINE LIB
    install(DIRECTORY ${DIR_LIB}/${TARGET_ABI}/ DESTINATION ${CMAKE_INSTALL_PREFIX}/libs/${TARGET_ABI})
    install(FILES ${CMAKE_BINARY_DIR}/libNSProject.so DESTINATION ${CMAKE_INSTALL_PREFIX}/libs/${TARGET_ABI})
	if( EXISTS "${PROJECT_SOURCE_DIR}/Libs/${TARGET_ABI}/" )
		install(DIRECTORY ${PROJECT_SOURCE_DIR}/Libs/${TARGET_ABI}/ DESTINATION ${CMAKE_INSTALL_PREFIX}/libs/${TARGET_ABI})
	endif()
elseif (NOT ${NS_EXPORT_LIB})
    set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/install/${PROJECT_NAME})
    message(">>>>>>>>>>>>>>>>> PROJECT LINUX INSTALL PATH: " ${CMAKE_INSTALL_PREFIX})
    #INSTALL DEPENDENT LIB. DIR LIB IS NS ENGINE LIB
    install(DIRECTORY ${DIR_LIB}/${TARGET_ABI}/ DESTINATION ${CMAKE_INSTALL_PREFIX}/libs/${TARGET_ABI})
    install(FILES ${CMAKE_BINARY_DIR}/libNSProject.so DESTINATION ${CMAKE_INSTALL_PREFIX}/libs/${TARGET_ABI})
	if( EXISTS "${PROJECT_SOURCE_DIR}/Libs/${TARGET_ABI}/" )
		install(DIRECTORY ${PROJECT_SOURCE_DIR}/Libs/${TARGET_ABI}/ DESTINATION ${CMAKE_INSTALL_PREFIX}/libs/${TARGET_ABI})
	endif()
else()
    set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/export/NSProjectLib)
    message(">>>>>>>>>>>>>>>>> PROJECT LINUX EXPORT LIB INSTALL PATH: " ${CMAKE_INSTALL_PREFIX})
    install(DIRECTORY ${PROJECT_SOURCE_DIR}/install/${PROJECT_NAME}/EngineAssets DESTINATION ${CMAKE_INSTALL_PREFIX}/Resources)
    install(DIRECTORY ${PROJECT_SOURCE_DIR}/install/${PROJECT_NAME}/Assets DESTINATION ${CMAKE_INSTALL_PREFIX}/Resources)
    install(DIRECTORY ${ENGINE_ROOT_PATH}/include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/Include/)
    #INSTALL DEPENDENT LIB. DIR LIB IS NS ENGINE LIB
    install(DIRECTORY ${DIR_LIB}/${TARGET_ABI}/ DESTINATION ${CMAKE_INSTALL_PREFIX}/Libs/${TARGET_ABI})
    install(FILES ${CMAKE_BINARY_DIR}/libNSProject.so DESTINATION ${CMAKE_INSTALL_PREFIX}/Libs/${TARGET_ABI})
	if( EXISTS "${PROJECT_SOURCE_DIR}/Libs/${TARGET_ABI}/" )
		install(DIRECTORY ${PROJECT_SOURCE_DIR}/Libs/${TARGET_ABI}/ DESTINATION ${CMAKE_INSTALL_PREFIX}/Libs/${TARGET_ABI})
	endif()
endif()

if (NOT ${NS_EXPORT_LIB})
	install(TARGETS ${PROJECT_NAME} 
	       RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX} 
	       LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
	       ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
	)
else()
	install(TARGETS NSProject
	       RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/Libs/${TARGET_ABI} 
	       LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/Libs/${TARGET_ABI}
	       ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/Libs/${TARGET_ABI}
	)
endif()


if( EXISTS "${PROJECT_SOURCE_DIR}/CMake/InstallLinuxCustom.cmake" )
	include(${PROJECT_SOURCE_DIR}/CMake/InstallLinuxCustom.cmake)
endif() 
